---
title: Using OpenAPI Specifications
shortTitle: Using OpenAPI
layout: page
pageOrder: 3
section: 'Mock Server'
subsection: true
sitemap:
  priority: 0.8
  changefreq: 'monthly'
  lastmod: 2019-11-10T08:00:00+01:00
---

<p>MockServer supports <a target="_blank" href="https://swagger.io/docs/specification/basic-structure/"><strong>OpenAPI v3</strong></a> specifications in either JSON or YAML format.</p>

<p>OpenAPI specifications can be used in <a href="/mock_server/getting_started.html#request_openapi_matchers"><strong>request matchers</strong></a> for</p>
<ul>
  <li>expectation <a href="/mock_server/getting_started.html#request_openapi_matchers"><strong>request matchers</strong></a></li>
  <li><a href="/mock_server/verification.html"><strong>verifying requests</strong></a> and <a href="/mock_server/verification.html"><strong>verifying request sequences</strong></a></li>
  <li><a href="/mock_server/clearing_and_resetting.html"><strong>clearing logs</strong></a></li>
  <li>retrieving <a href="/mock_server/debugging_issues.html#retrieving_recorded_logs"><strong>logs</strong></a>, <a href="/mock_server/debugging_issues.html#retrieving_recorded_requests"><strong>recorded requests</strong></a> and <a href="/mock_server/debugging_issues.html#retrieving_active_expectations"><strong>expectations</strong></a></li>
</ul>

<p>OpenAPI specifications can also be used to <a href="#generate_expectation_from_openapi"><strong>generate expectations</strong></a> with example responses.</p>

<a id="generate_expectation_from_openapi" class="anchor" href="#generate_expectation_from_openapi">&nbsp;</a>

<h2>Generate Expectations From OpenAPI</h2>

<p>MockServer supports <strong>open api expectations</strong> containing the follow fields:</p>
<ul>
    <li><strong>specUrlOrPayload</strong> - mandatory value containing an <a target="_blank" href="https://swagger.io/docs/specification/basic-structure/"><strong>OpenAPI v3</strong></a> specifications in either JSON or YAML format as an:
        <ul>
            <li><strong><a href="#button_open_api_remote_specification">HTTP/HTTPS URL</a></strong></li>
            <li><strong><a href="#button_open_api_filepath">File URL</a></strong></li>
            <li><strong><a href="#button_open_api_classpath">classpath location</a></strong> (without the classpath: scheme)</li>
            <li><strong><a href="#button_open_api_inline_json_specification">inline JSON object</a></strong></li>
            <li><strong><a href="#button_open_api_inline_yaml_specification">inline escaped YAML string</a></strong></li>
        </ul>
    </li>
    <li><strong><a href="#button_open_api_remote_specification_with_filtering">operationsAndResponses</a></strong>
        <ul>
            <li>optional value that specifies which specifies operations are included, if not specified all operations are included</li>
            <li>specified which response body when multiple response bodies are specified (i.e. different status codes), if not specified the first response body is used</li>
            <li>fields names are <strong>operationId</strong> indicating the operation in the OpenAPI specification</li>
            <li>field values are a string <strong>statusCode</strong> (such as "200", "400" or "default") indicating the response body for the specified operation</li>
        </ul>
    </li>
</ul>

<p>For each <strong>open api expectations</strong> MockServer creates multiple <strong><a href="/mock_server/creating_expectations.html">request matcher expectations</a></strong> as follows:</p>
<ul>
    <li><strong>request matcher</strong>
        <ul>
            <li>each expectation will use an <a href="/mock_server/getting_started.html#request_openapi_matchers"><strong>open api request matcher</strong></a> to match requests.</li>
        </ul></li>
    <li><strong>action</strong>
        <ul>
            <li>a <a href="/mock_server/creating_expectations.html#response_action"><strong>response</strong></a> action is added to each expectation using <a target="_blank" href="https://swagger.io/docs/specification/adding-examples/">examples provided in the specification</a></li>
            <li>if no examples are provided in the specification then the <a href="/mock_server/creating_expectations.html#response_action"><strong>response</strong></a> is auto-generated from schema definitions for response body and headers of the operation</li>
            <li>if multiple response bodies are specified for an operation (i.e. different status codes) the first response body is used by default, however this can be controlled by using <strong>operationsAndResponses</strong></li>
        </ul>
    </li>
</ul>

<p></p>


<p></p>

<a id="generate_expectation_from_openapi_example" class="anchor" href="#generate_expectation_from_openapi_example">&nbsp;</a>

<p>If an <a target="_blank" href="https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json">OpenAPI specification</a> is submitted with operation filtering as follows:</p>

<pre class="prettyprint lang-java code"><code class="code">{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationsAndResponses": {
        "showPetById": "200",
        "createPets": "500"
    }
}</code></pre>

<p>Then the following expectations are created:</p>

<pre class="prettyprint lang-java code"><code class="code">{
  "priority": 0,
  "httpRequest": {
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
  },
  "httpResponse": {
    "statusCode": 200,
    "headers": {
      "content-type": [
        "application/json"
      ]
    },
    "body": {
      "id": 0,
      "name": "some_string_value",
      "tag": "some_string_value"
    }
  },
  "times": {
    "unlimited": true
  },
  "timeToLive": {
    "unlimited": true
  }
}</code></pre>
<pre class="prettyprint lang-java code"><code class="code">{
  "priority": 0,
  "httpRequest": {
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "createPets"
  },
  "httpResponse": {
    "statusCode": 500,
    "headers": {
      "content-type": [
        "application/json"
      ]
    },
    "body": {
      "code": 0,
      "message": "some_string_value"
    }
  },
  "times": {
    "unlimited": true
  },
  "timeToLive": {
    "unlimited": true
  }
}</code></pre>

<a id="generate_expectation_from_openapi_code_examples" class="anchor" href="#generate_expectation_from_openapi_code_examples">&nbsp;</a>

<button id="button_open_api_remote_specification" class="accordion">create expectation from a remote specification</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .upsert(
        openAPIExpectation(
            "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
        )
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).openAPIExpectation({
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/openapi" -d '{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
}'</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_open_api_remote_specification_with_filtering" class="accordion">create expectation from a remote specification filtering operations and controlling response bodies</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
<pre class="prettyprint lang-java code"><code class="code">Map&lt;String, String&gt; operationsAndResponses = new HashMap<>();
operationsAndResponses.put("showPetById", "200");
operationsAndResponses.put("createPets", "500");
new MockServerClient("localhost", 1080)
    .upsert(
        openAPIExpectation(
            "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
            operationsAndResponses
        )
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).openAPIExpectation({
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationsAndResponses": {
        "showPetById": "200",
        "createPets": "500"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/openapi" -d '{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationsAndResponses": {
        "showPetById": "200",
        "createPets": "500"
    }
}'</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_open_api_filepath" class="accordion">create expectation from file path</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .upsert(
        openAPIExpectation(
            "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
        )
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).openAPIExpectation({
    "specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/openapi" -d '{
    "specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
}'</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_open_api_classpath" class="accordion">create expectation from classpath location</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .upsert(
        openAPIExpectation("org/mockserver/openapi/openapi_petstore_example.json")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).openAPIExpectation({
    "specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/openapi" -d '{
    "specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
}'</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_open_api_inline_json_specification" class="accordion">create expectation from an inline json specification</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .upsert(
        openAPIExpectation(FileReader.readFileFromClassPathOrPath("/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"))
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var fs = require('fs');
try {
    var mockServerClient = require('mockserver-client').mockServerClient;
    mockServerClient("localhost", 1080).openAPIExpectation({
        "specUrlOrPayload": fs.readFileSync("/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json", "utf8")
    }).then(
        function () {
            console.log("expectation created");
        },
        function (error) {
            console.log(error);
        }
    );
} catch (e) {
    console.log('Error:', e.stack);
}</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/openapi" -d "{
    \"specUrlOrPayload\": `cat /Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json`
}"</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_open_api_inline_yaml_specification" class="accordion">create expectation from an inline yaml specification</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .upsert(
        openAPIExpectation("---\n" +
            "openapi: 3.0.0\n" +
            "info:\n" +
            "  version: 1.0.0\n" +
            "  title: Swagger Petstore\n" +
            "  license:\n" +
            "    name: MIT\n" +
            "servers:\n" +
            "  - url: http://petstore.swagger.io/v1\n" +
            "paths:\n" +
            "  /pets:\n" +
            "    get:\n" +
            "      summary: List all pets\n" +
            "      operationId: listPets\n" +
            "      tags:\n" +
            "        - pets\n" +
            "      parameters:\n" +
            "        - name: limit\n" +
            "          in: query\n" +
            "          description: How many items to return at one time (max 100)\n" +
            "          required: false\n" +
            "          schema:\n" +
            "            type: integer\n" +
            "            format: int32\n" +
            "      responses:\n" +
            "        '200':\n" +
            "          description: A paged array of pets\n" +
            "          headers:\n" +
            "            x-next:\n" +
            "              description: A link to the next page of responses\n" +
            "              schema:\n" +
            "                type: string\n" +
            "              examples:\n" +
            "                two:\n" +
            "                  value: \"/pets?query=752cd724e0d7&page=2\"\n" +
            "                end:\n" +
            "                  value: \"\"\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Pets'\n" +
            "        '500':\n" +
            "          description: unexpected error\n" +
            "          headers:\n" +
            "            x-code:\n" +
            "              description: The error code\n" +
            "              schema:\n" +
            "                type: integer\n" +
            "                format: int32\n" +
            "                example: 90\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Error'\n" +
            "        default:\n" +
            "          description: unexpected error\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Error'\n" +
            "    post:\n" +
            "      summary: Create a pet\n" +
            "      operationId: createPets\n" +
            "      tags:\n" +
            "        - pets\n" +
            "      requestBody:\n" +
            "        description: a pet\n" +
            "        required: true\n" +
            "        content:\n" +
            "          application/json:\n" +
            "            schema:\n" +
            "              $ref: '#/components/schemas/Pet'\n" +
            "          '*/*':\n" +
            "            schema:\n" +
            "              $ref: '#/components/schemas/Pet'\n" +
            "      responses:\n" +
            "        '201':\n" +
            "          description: Null response\n" +
            "        '400':\n" +
            "          description: unexpected error\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Error'\n" +
            "        '500':\n" +
            "          description: unexpected error\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Error'\n" +
            "        default:\n" +
            "          description: unexpected error\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Error'\n" +
            "  /pets/{petId}:\n" +
            "    get:\n" +
            "      summary: Info for a specific pet\n" +
            "      operationId: showPetById\n" +
            "      tags:\n" +
            "        - pets\n" +
            "      parameters:\n" +
            "        - name: petId\n" +
            "          in: path\n" +
            "          required: true\n" +
            "          description: The id of the pet to retrieve\n" +
            "          schema:\n" +
            "            type: string\n" +
            "        - in: header\n" +
            "          name: X-Request-ID\n" +
            "          schema:\n" +
            "            type: string\n" +
            "            format: uuid\n" +
            "          required: true\n" +
            "      responses:\n" +
            "        '200':\n" +
            "          description: Expected response to a valid request\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Pet'\n" +
            "              examples:\n" +
            "                Crumble:\n" +
            "                  value:\n" +
            "                    id: 2\n" +
            "                    name: Crumble\n" +
            "                    tag: dog\n" +
            "                Boots:\n" +
            "                  value:\n" +
            "                    id: 3\n" +
            "                    name: Boots\n" +
            "                    tag: cat\n" +
            "        '500':\n" +
            "          description: unexpected error\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Error'\n" +
            "        default:\n" +
            "          description: unexpected error\n" +
            "          content:\n" +
            "            application/json:\n" +
            "              schema:\n" +
            "                $ref: '#/components/schemas/Error'\n" +
            "components:\n" +
            "  schemas:\n" +
            "    Pet:\n" +
            "      type: object\n" +
            "      required:\n" +
            "        - id\n" +
            "        - name\n" +
            "      properties:\n" +
            "        id:\n" +
            "          type: integer\n" +
            "          format: int64\n" +
            "        name:\n" +
            "          type: string\n" +
            "        tag:\n" +
            "          type: string\n" +
            "      example:\n" +
            "        id: 1\n" +
            "        name: Scruffles\n" +
            "        tag: dog\n" +
            "    Pets:\n" +
            "      type: array\n" +
            "      items:\n" +
            "        $ref: '#/components/schemas/Pet'\n" +
            "    Error:\n" +
            "      type: object\n" +
            "      required:\n" +
            "        - code\n" +
            "        - message\n" +
            "      properties:\n" +
            "        code:\n" +
            "          type: integer\n" +
            "          format: int32\n" +
            "        message:\n" +
            "          type: string\n")
    );
}</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).openAPIExpectation({
    "specUrlOrPayload": "---\n" +
        "openapi: 3.0.0\n" +
        "info:\n" +
        "  version: 1.0.0\n" +
        "  title: Swagger Petstore\n" +
        "  license:\n" +
        "    name: MIT\n" +
        "servers:\n" +
        "  - url: http://petstore.swagger.io/v1\n" +
        "paths:\n" +
        "  /pets:\n" +
        "    get:\n" +
        "      summary: List all pets\n" +
        "      operationId: listPets\n" +
        "      tags:\n" +
        "        - pets\n" +
        "      parameters:\n" +
        "        - name: limit\n" +
        "          in: query\n" +
        "          description: How many items to return at one time (max 100)\n" +
        "          required: false\n" +
        "          schema:\n" +
        "            type: integer\n" +
        "            format: int32\n" +
        "      responses:\n" +
        "        '200':\n" +
        "          description: A paged array of pets\n" +
        "          headers:\n" +
        "            x-next:\n" +
        "              description: A link to the next page of responses\n" +
        "              schema:\n" +
        "                type: string\n" +
        "              examples:\n" +
        "                two:\n" +
        "                  value: \"/pets?query=752cd724e0d7&page=2\"\n" +
        "                end:\n" +
        "                  value: \"\"\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Pets'\n" +
        "        '500':\n" +
        "          description: unexpected error\n" +
        "          headers:\n" +
        "            x-code:\n" +
        "              description: The error code\n" +
        "              schema:\n" +
        "                type: integer\n" +
        "                format: int32\n" +
        "                example: 90\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Error'\n" +
        "        default:\n" +
        "          description: unexpected error\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Error'\n" +
        "    post:\n" +
        "      summary: Create a pet\n" +
        "      operationId: createPets\n" +
        "      tags:\n" +
        "        - pets\n" +
        "      requestBody:\n" +
        "        description: a pet\n" +
        "        required: true\n" +
        "        content:\n" +
        "          application/json:\n" +
        "            schema:\n" +
        "              $ref: '#/components/schemas/Pet'\n" +
        "          '*/*':\n" +
        "            schema:\n" +
        "              $ref: '#/components/schemas/Pet'\n" +
        "      responses:\n" +
        "        '201':\n" +
        "          description: Null response\n" +
        "        '400':\n" +
        "          description: unexpected error\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Error'\n" +
        "        '500':\n" +
        "          description: unexpected error\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Error'\n" +
        "        default:\n" +
        "          description: unexpected error\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Error'\n" +
        "  /pets/{petId}:\n" +
        "    get:\n" +
        "      summary: Info for a specific pet\n" +
        "      operationId: showPetById\n" +
        "      tags:\n" +
        "        - pets\n" +
        "      parameters:\n" +
        "        - name: petId\n" +
        "          in: path\n" +
        "          required: true\n" +
        "          description: The id of the pet to retrieve\n" +
        "          schema:\n" +
        "            type: string\n" +
        "        - in: header\n" +
        "          name: X-Request-ID\n" +
        "          schema:\n" +
        "            type: string\n" +
        "            format: uuid\n" +
        "          required: true\n" +
        "      responses:\n" +
        "        '200':\n" +
        "          description: Expected response to a valid request\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Pet'\n" +
        "              examples:\n" +
        "                Crumble:\n" +
        "                  value:\n" +
        "                    id: 2\n" +
        "                    name: Crumble\n" +
        "                    tag: dog\n" +
        "                Boots:\n" +
        "                  value:\n" +
        "                    id: 3\n" +
        "                    name: Boots\n" +
        "                    tag: cat\n" +
        "        '500':\n" +
        "          description: unexpected error\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Error'\n" +
        "        default:\n" +
        "          description: unexpected error\n" +
        "          content:\n" +
        "            application/json:\n" +
        "              schema:\n" +
        "                $ref: '#/components/schemas/Error'\n" +
        "components:\n" +
        "  schemas:\n" +
        "    Pet:\n" +
        "      type: object\n" +
        "      required:\n" +
        "        - id\n" +
        "        - name\n" +
        "      properties:\n" +
        "        id:\n" +
        "          type: integer\n" +
        "          format: int64\n" +
        "        name:\n" +
        "          type: string\n" +
        "        tag:\n" +
        "          type: string\n" +
        "      example:\n" +
        "        id: 1\n" +
        "        name: Scruffles\n" +
        "        tag: dog\n" +
        "    Pets:\n" +
        "      type: array\n" +
        "      items:\n" +
        "        $ref: '#/components/schemas/Pet'\n" +
        "    Error:\n" +
        "      type: object\n" +
        "      required:\n" +
        "        - code\n" +
        "        - message\n" +
        "      properties:\n" +
        "        code:\n" +
        "          type: integer\n" +
        "          format: int32\n" +
        "        message:\n" +
        "          type: string\n"
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a target="_blank" href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank">REST API</a> for full JSON specification</p>
    </div>
</div>
